package ${package.Enum};

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.pine.common.beans.enums.${enumCodeType}CodeBaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * <p>
 * ${table.comment!}-${enumChineseName} 枚举
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@AllArgsConstructor
@Getter
public enum ${EnumName} implements ${enumCodeType}CodeBaseEnum {
<#list enumCodeAndDescList as enumCodeAndDesc>
    <#if enumCodeType == "Integer">
    ${enumCodeAndDesc.codeName}(${enumCodeAndDesc.code}, "${enumCodeAndDesc.desc}"),
    <#elseif enumCodeType == "String">
    ${enumCodeAndDesc.codeName}("${enumCodeAndDesc.code}", "${enumCodeAndDesc.desc}"),
    </#if>
</#list>
    ;

    @EnumValue
    private final ${enumCodeType} code;
    private final String desc;

    public static ${EnumName} of(${enumCodeType} code) {
        return Arrays.stream(${EnumName}.values()).filter(${lowerFirstCharEnumName} -> Objects.equals(${lowerFirstCharEnumName}.code, code)).findAny().orElse(null);
    }
}
